#pragma once
#include <iostream>
#include <string>

class Task
{
private:
    int _data1;
    int _data2;
    int _result;
    int _exitcode;
    char _operator;
    

public:
    Task(int x, int y,char op)
        : _data1(x), _data2(y), _result(0), _operator(op), _exitcode(0)
    {
    }

    void run()
    {
        switch (_operator)
        {
        case '+':
            _result=_data1+_data2;
            break;
        case '-':
            _result=_data1-_data2;
            break;
        case '*':
            _result=_data1*_data2;
            break;
        case '/':
            {
                if(_data2==0)
                    _exitcode=1;
                else
                    _result=_data1/_data2;
            }
            break;
        case '%':
            {
                if(_data2==0)
                    _exitcode=1;
                else
                    _result=_data1%_data2;
            }
            break;
        default:
            _exitcode=3;
            break;
        }       
    }
    void operator()()
    {
        run();
    }
    std::string GetResult()
    {
        std::string r;
        r+=std::to_string(_data1);
        r+=_operator;
        r+=std::to_string(_data2);
        r+="=(";
        r+=std::to_string(_result);
        r+=") ";
        r+="[exit code: ";
        r+=std::to_string(_exitcode);
        r+="]";
        return r;
    }
    std::string GetTask()
    {
        std::string r;
        r+=std::to_string(_data1);
        r+=_operator;
        r+=std::to_string(_data2);
        r+="=?";
        return r;
    }
    
    ~Task()
    {
    }
};